﻿<%@ page contentType="text/html; charset=UTF-8" %>
<div class="searchBar">
组织机构全称：<input id="s_dataorganizations_cpName" name="s_dataorganizations_cpName" type="text" class="box-input">&nbsp;&nbsp;
所属地区：<select id="s_dataorganizations_areaId" name="s_dataorganizations_areaId">
<option value="" selected>--全部--</option>
</select>&nbsp;&nbsp;
机构性质：<select id="s_dataorganizations_cpNature" name="s_dataorganizations_cpNature">
          <option value="" selected>--请选择--</option>
          <option value="1">SI管理系统</option>
          <option value="2">SI自服系统</option>
          <option value="3">EC自服务系统</option>
          <option value="9">其它</option>
</select>
<input id="s_dataorganizations" type="button" class="btns" value="查  询">
</div>

<table id="dataorganizations_grid"></table>      
<div id="dataorganizations_page"></div>  

<div id="dataorganizations_dialog_add" title="新增组织机构">
<form id="dataorganizations_form_add" name="dataorganizations_form_add" style="width:600px;" class="cmxform" method="POST">
    <div id="dataorganizations_add_errmsg"></div>
    <table width="100%" align="center" border="0" cellspacing="0" cellpadding="0" class="jkt-tableStyle">
	<tr>
        <td class="bluetd" align="right">地区：</td>
        <td class="bluetd" align="left">
        <div class="zTreeDemoBackground">
            <input id="dataorganizations_citySel_add" type="text" readonly />
			&nbsp;<a id="menuBtn_dadd" href="#" onclick="showDataorganizationsMenu_add(); return false;">选择</a><span class="red-color">*</span>
			</div>
			<input type="hidden" id="dataorganizations_areaId_add" name="dataorganizations_areaId_add" value="" />
        </td>
        <td class="bluetd" align="right">代码：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_cpCode_add" name="dataorganizations_cpCode_add"><span class="red-color">*</span>
        </td>
     </tr>
	<tr>
        <td class="bluetd2" align="right">全称：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_cpName_add" name="dataorganizations_cpName_add"><span class="red-color">*</span>
        </td>
        <td class="bluetd2" align="right">简称：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_abbreviation_add" name="dataorganizations_abbreviation_add"><span class="red-color">*</span>
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">合作伙伴类型：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_coopType_add" name="dataorganizations_coopType_add"><span class="red-color">*</span>
        </td>
         <td class="bluetd" align="right">公司介绍：</td>
         <td  class="bluetd" align="left">
          <input id="dataorganizations_aboutInfo_add" name="dataorganizations_aboutInfo_add">
        </td>
     </tr>
	<tr>
        <td class="bluetd2" align="right">机构性质：</td>
        <td class="bluetd2" align="left">
          <select style="width:140px" id="dataorganizations_cpNature_add" name="dataorganizations_cpNature_add">
          <option value="-1">——请选择——</option>
          <option value="1">SI管理系统</option>
          <option value="2">SI自服系统</option>
          <option value="3">EC自服务系统</option>
          <option value="9">其它</option>
        </select><span class="red-color">*</span>
        </td>
        <td class="bluetd2" align="right">公司电话：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_phoneValue_add" name="dataorganizations_phoneValue_add">
        </td>
        
     </tr>
	<tr>
        <td class="bluetd" align="right">合同开始时间：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_beginTime_addString" name="dataorganizations_beginTime_addString">
        </td>
        <td class="bluetd" align="right">电子合同号：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_contrNo_add" name="dataorganizations_contrNo_add">
        </td>
     </tr>
	<tr>
        <td class="bluetd2" align="right">合同有效期：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_contrPeriod_addString" name="dataorganizations_contrPeriod_addString">
        </td>
        <td class="bluetd2" align="right">企业法人：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_corporate_add" name="dataorganizations_corporate_add">
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">注册地址：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_regAddress_add" name="dataorganizations_regAddress_add">
        </td>
        <td class="bluetd" align="right">办公地址：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_offAddress_add" name="dataorganizations_offAddress_add">
        </td>
     </tr>
	<tr>
        <td class="bluetd2" align="right">联系人：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_contact_add" name="dataorganizations_contact_add"><span class="red-color">*</span>
        </td>
        <td class="bluetd2" align="right">联系电话：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_mobileNo_add" name="dataorganizations_mobileNo_add"><span class="red-color">*</span>
        </td>
     </tr>
      <tr>
        <td colspan="4" align="center">
         <input type="button" class="btns" id="dataorganizations_add_bt" value="新  增" style="margin-top:8px;" />&nbsp;&nbsp;
         <input type="button" class="btns" id="dataorganizations_add_close" value="关  闭" style="margin-top:8px;" />
      </td>
</tr>
<div id="ataorganizations_add_dm" style="display:none; position:absolute;height:212px; min-width:150px; background-color:white;border:1px solid;overflow-y:auto;overflow-x:auto;">
	<ul id="ataorganizations_dMenu_add" class="tree"></ul>
</div>
</table>
</form>
</div> 


<div id="dataorganizations_dialog_up" title="修改组织机构">
<form id="dataorganizations_form_up" name="dataorganizations_form_up" style="width:600px;" class="cmxform" method="POST">
    <div id="dataorganizations_up_errmsg"></div>
    <table width="100%" align="center" border="0" cellspacing="0" cellpuping="0" class="jkt-tableStyle">
	<tr>
        <td class="bluetd" align="right">地区：</td>
        <td class="bluetd" align="left">
        <div class="zTreeDemoBackground">
            <input id="dataorganizations_citySel_up" type="text" readonly />
			&nbsp;<a id="menuBtn_dup" href="#" onclick="showDataorganizationsMenu_up(); return false;">选择</a><span class="red-color">*</span>
			</div>
			<input type="hidden" id="dataorganizations_areaId_up" name="dataorganizations_areaId_up" value="" />
        </td>
        <td class="bluetd" align="right">代码：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_cpCode_up" name="dataorganizations_cpCode_up"><span class="red-color">*</span>
        </td>
     </tr>
	<tr>
        <td class="bluetd2" align="right">全称：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_cpName_up" name="dataorganizations_cpName_up"><span class="red-color">*</span>
        </td>
        <td class="bluetd2" align="right">简称：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_abbreviation_up" name="dataorganizations_abbreviation_up"><span class="red-color">*</span>
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">合作伙伴类型：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_coopType_up" name="dataorganizations_coopType_up"><span class="red-color">*</span>
        </td>
         <td class="bluetd" align="right">公司介绍：</td>
         <td  class="bluetd" align="left">
          <input id="dataorganizations_aboutInfo_up" name="dataorganizations_aboutInfo_up">
        </td>
     </tr>
	<tr>
        <td class="bluetd2" align="right">机构性质：</td>
        <td class="bluetd2" align="left">
          <select style="width:140px" id="dataorganizations_cpNature_up" name="dataorganizations_cpNature_up">
          <option value="-1">——请选择——</option>
          <option value="1">SI管理系统</option>
          <option value="2">SI自服系统</option>
          <option value="3">EC自服务系统</option>
          <option value="9">其它</option>
        </select><span class="red-color">*</span>
        </td>
        <td class="bluetd2" align="right">公司电话：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_phoneValue_up" name="dataorganizations_phoneValue_up">
        </td>
        
     </tr>
	<tr>
        <td class="bluetd" align="right">合同开始时间：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_beginTime_upString" name="dataorganizations_beginTime_upString">
        </td>
        <td class="bluetd" align="right">电子合同号：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_contrNo_up" name="dataorganizations_contrNo_up">
        </td>
     </tr>
	<tr>
        <td class="bluetd2" align="right">合同有效期：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_contrPeriod_upString" name="dataorganizations_contrPeriod_upString">
        </td>
        <td class="bluetd2" align="right">企业法人：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_corporate_up" name="dataorganizations_corporate_up">
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">注册地址：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_regAddress_up" name="dataorganizations_regAddress_up">
        </td>
        <td class="bluetd" align="right">办公地址：</td>
        <td class="bluetd" align="left">
          <input id="dataorganizations_offAddress_up" name="dataorganizations_offAddress_up">
        </td>
     </tr>
	<tr>
        <td class="bluetd2" align="right">联系人：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_contact_up" name="dataorganizations_contact_up"><span class="red-color">*</span>
        </td>
        <td class="bluetd2" align="right">联系电话：</td>
        <td class="bluetd2" align="left">
          <input id="dataorganizations_mobileNo_up" name="dataorganizations_mobileNo_up"><span class="red-color">*</span>
        </td>
     </tr>
     
     <tr>
        <td class="bluetd" align="right">状态：</td>
        <td colspan="3" class="bluetd" align="left">
          <select style="width:140px" id="dataorganizations_modeValue_up" name="dataorganizations_modeValue_up">
          <option value="-1">——请选择——</option>
          <option value="1">初始化</option>
          <option value="2">开通</option>
          <option value="4">暂停</option>
          <option value="5">停止</option>
        </select><span class="red-color">*</span>
        </td>
     </tr>

      <tr>
        <td colspan="4" align="center">
         <input type="button" class="btns" id="dataorganizations_up_bt" value="修  改" style="margin-top:8px;" />&nbsp;&nbsp;
         <input type="button" class="btns" id="dataorganizations_up_close" value="关  闭" style="margin-top:8px;" />
      </td>
</tr>
<div id="ataorganizations_up_dm" style="display:none; position:absolute;height:212px; min-width:150px; background-color:white;border:1px solid;overflow-y:auto;overflow-x:auto;">
	<ul id="ataorganizations_dMenu_up" class="tree"></ul>
</div>
</table>
</form>
</div> 

<script>

    var dataorganizationsdata={};//本页变量
    dataorganizationsdata.addvalidate;
    dataorganizationsdata.upvalidate;
    dataorganizationsdata.ids='';
    dataorganizationsdata.addset;
    dataorganizationsdata.upset;
    dataorganizationsdata.addNodes=[];
    dataorganizationsdata.upNodes=[];
    dataorganizationsdata.addval=false;
    dataorganizationsdata.upval=false;
    
	jQuery("#dataorganizations_grid").jqGrid({//列表
        datatype: "json", 
        hidegrid: false, //不显示收缩
        url:'organiza/DataOrganizations/list.do',
        height:dataorganizationsgridHeight,
        forceFit: true,//调整宽度不改变表格宽度
        width: dataorganizationsgridWidth,
        colNames:[
        '编号'
        ,'higherId'
        ,'代码'
        ,'全称'
        ,'简称'
        ,'公司介绍'
        ,'地区id'
        ,'地区'
        ,'机构性质'
        ,'状态'
        ,'合作伙伴类型'
        ,'合同开始时间'
        ,'电子合同号'
        ,'合同有效期'
        ,'企业法人'
        ,'注册地址'
        ,'办公地址'
        ,'联系人'
        ,'联系电话'
        ,'公司电话'
        ,'审核时间'
        ,'开通时间'
        ,'开通人'
        ,'是否同步'
	    ],
        colModel:[
        {name:'id',index:'id', width:160,sorttype:'int',sortable:false}  
        ,{name:'higherId',index:'higherId',width:120,sortable:false}
        ,{name:'cpCode',index:'cpCode',width:100,sortable:false}
        ,{name:'cpName',index:'cpName',width:140,sortable:false}
        ,{name:'abbreviation',index:'abbreviation',width:120,sortable:false}
        ,{name:'aboutInfo',index:'aboutInfo',width:160,sortable:false}
        ,{name:'areaId',index:'areaId',width:2,sortable:false}
        ,{name:'areaName',index:'areaName',width:140,sortable:false}
        ,{name:'cpNature',index:'cpNature',width:110,sortable:false,formatter:fun_dataorganizations_formatcpNature}
        ,{name:'modeValue',index:'modeValue',width:100,sortable:false,formatter:fun_dataorganizations_formatmodeValue}
        ,{name:'coopType',index:'coopType',width:2,sortable:false}
        ,{name:'beginTimeString',index:'beginTimeString',width:2,sortable:false}
        ,{name:'contrNo',index:'contrNo',width:2,sortable:false}
        ,{name:'contrPeriodString',index:'contrPeriodString',width:2,sortable:false}
        ,{name:'corporate',index:'corporate',width:2,sortable:false}
        ,{name:'regAddress',index:'regAddress',width:2,sortable:false}
        ,{name:'offAddress',index:'offAddress',width:2,sortable:false}
        ,{name:'contact',index:'contact',width:2,sortable:false}
        ,{name:'mobileNo',index:'mobileNo',width:2,sortable:false}
        ,{name:'phoneValue',index:'phoneValue',width:2,sortable:false}
        ,{name:'auditTime',index:'auditTime',width:2,sortable:false}
        ,{name:'openTime',index:'openTime',width:2,sortable:false}
        ,{name:'openPeople',index:'openPeople',width:2,sortable:false}
        ,{name:'syncCpCode',index:'syncCpCode',width:100,sortable:false,formatter:fun_dataorganizations_formatsyncCpCode}
        
        ],
        multiselect: true,//禁止多选
        toolbar:[true,'top'],
        rowNum:10, //每页显示的数据条数
        rowList:[5,10,20],  //分页条数选项
        viewrecords: true, 
        sortname:  "id" , //默认排序的列名    
        sortorder: "desc", 
        pager: '#dataorganizations_page', 
        jsonReader: {     
          root: 'dataRows',   
          repeatitems : false     
        }
    })
    
    $("#t_dataorganizations_grid").append("<div style='width:25%;' class='l'>机构管理->组织机构列表</div><div class='r text-r' style='width:60%; height:28px'>"
       +"<a href='javascript:void(0)' onclick=\"fun_dataorganizations_update()\" class='modify r'>修改</a>"
       +"<a href='javascript:void(0)' onclick=\"fun_dataorganizations_delete()\" class='del r'>删除</a> "
       +"</div>");//列表头
       
    $("#t_dataorganizations_grid").removeClass("ui-userdata ui-state-default"); //删样式
    $("#t_dataorganizations_grid").addClass("ui-title ui-corner-top ui-helper-clearfix");//加样式
    
    jQuery("#dataorganizations_grid").jqGrid('hideCol',['higherId','areaId','coopType','beginTimeString','contrNo','contrPeriodString','corporate','regAddress','offAddress','contact','mobileNo','phoneValue','auditTime','openTime','openPeople']);//隐藏列
    $("#dataorganizations_grid").closest(".ui-jqgrid-bdiv").css({ 'overflow-x' : 'hidden' });//隐藏横向滚动条
    
    function fun_dataorganizations_formatcpNature(cellvalue, options, rowObject){
        if(rowObject.cpNature==1){
            return ("SI管理系统");
        }else if(rowObject.cpNature==2){
            return ("SI自服系统");
        }else if(rowObject.cpNature==3){
            return ("EC自服务系统");
        }else{
            return ("其它");
        }
    }
    function fun_dataorganizations_formatsyncCpCode(cellvalue, options, rowObject){
        if(rowObject.syncCpCode==10){
            return ("已同步");
        }else if(rowObject.syncCpCode==20){
            return ("未同步");
        }else{
            return ("未操作");
        }
    }
    function fun_dataorganizations_formatmodeValue(cellvalue, options, rowObject){
        if(rowObject.modeValue==1){
            return ("正常");
        }else if(rowObject.modeValue==2){
            return ("开通");
        }else if(rowObject.modeValue==4){
            return ("暂停");
        }else{
            return ("停止");
        }
    }
    
    function fun_dataorganizations_add(){//新增操作
		$("#dataorganizations_form_add")[0].reset();
		$('#dataorganizations_add_errmsg').html("");
		dataorganizationsdata.addval=false;
		$("#dataorganizations_dialog_add").dialog("open");
		$("#dataorganizations_dialog_add").dialog('option' , 'height',[dataorganizationsaddDialogHeight()]);
	}
    
    $('#dataorganizations_add_bt').click(function(){//点击按妞
         if(rulesByValidator(dataorganizationsdata.addvalidate)){
             dataorganizations_add_submit();
         }
     })
     
     function  dataorganizations_add_submit(){//新增提交
        var dataorganizationsJson="{'cpCode':'"+$('#dataorganizations_cpCode_add').val()+"','cpName':'"+$('#dataorganizations_cpName_add').val()+"','abbreviation':'"+$('#dataorganizations_abbreviation_add').val()+"','aboutInfo':'"+$('#dataorganizations_aboutInfo_add').val()+"','areaId':'"+$('#dataorganizations_areaId_add').val()+"','cpNature':'"+$('#dataorganizations_cpNature_add').val()+"','coopType':'"+$('#dataorganizations_coopType_add').val()+"','beginTimeString':'"+$('#dataorganizations_beginTime_addString').val()+"','contrNo':'"+$('#dataorganizations_contrNo_add').val()+"','contrPeriodString':'"+$('#dataorganizations_contrPeriod_addString').val()+"','corporate':'"+$('#dataorganizations_corporate_add').val()+"','regAddress':'"+$('#dataorganizations_regAddress_add').val()+"','offAddress':'"+$('#dataorganizations_offAddress_add').val()+"','contact':'"+$('#dataorganizations_contact_add').val()+"','mobileNo':'"+$('#dataorganizations_mobileNo_add').val()+"','modeValue':'1','phoneValue':'"+$('#dataorganizations_phoneValue_add').val()+"','openPeople':'"+mDiv.userName+"'}";  
         $.ajax({
             type: "POST",
             url:"organiza/DataOrganizations/save.do",
             data:{
                 dataorganizationsJson:dataorganizationsJson
             },
             dataType: "json",
             contentType: "application/x-www-form-urlencoded; charset=UTF-8",
             success:function(json){
                 if(json.success){
                     $("#dataorganizations_grid").trigger("reloadGrid");
                     alertmsg(json.msg,"info");
                 }else{
                     alertmsg(json.msg,"alert");
                 }
             }
         })
     }
     
     $('#dataorganizations_add_close').click(function(){//关闭
         $("#dataorganizations_dialog_add").dialog('close');
     })
     
      $('#dataorganizations_up_bt').click(function(){//点击按妞
         if(rulesByValidator(dataorganizationsdata.upvalidate)){
              dataorganizations_update_submit();
         }
     })
        
     function  dataorganizations_update_submit(){//修改提交
         var dataorganizationsJson="{'id':'"+rowData.id+"','cpCode':'"+$('#dataorganizations_cpCode_up').val()+"','cpName':'"+$('#dataorganizations_cpName_up').val()+"','abbreviation':'"+$('#dataorganizations_abbreviation_up').val()+"','aboutInfo':'"+$('#dataorganizations_aboutInfo_up').val()+"','areaId':'"+$('#dataorganizations_areaId_up').val()+"','cpNature':'"+$('#dataorganizations_cpNature_up').val()+"','coopType':'"+$('#dataorganizations_coopType_up').val()+"','beginTimeString':'"+$('#dataorganizations_beginTime_upString').val()+"','contrNo':'"+$('#dataorganizations_contrNo_up').val()+"','contrPeriodString':'"+$('#dataorganizations_contrPeriod_upString').val()+"','corporate':'"+$('#dataorganizations_corporate_up').val()+"','regAddress':'"+$('#dataorganizations_regAddress_up').val()+"','offAddress':'"+$('#dataorganizations_offAddress_up').val()+"','contact':'"+$('#dataorganizations_contact_up').val()+"','mobileNo':'"+$('#dataorganizations_mobileNo_up').val()+"','modeValue':'"+$('#dataorganizations_modeValue_up').val()+"','phoneValue':'"+$('#dataorganizations_phoneValue_up').val()+"'}";  
         $.ajax({
             type: "POST",
             url:"organiza/DataOrganizations/update.do",
             data:{
                 dataorganizationsJson:dataorganizationsJson
             },
             dataType: "json",
             contentType: "application/x-www-form-urlencoded; charset=UTF-8",
             success:function(json){
                 if(json.success){
                     $("#dataorganizations_grid").trigger("reloadGrid");
                     alertmsg(json.msg,"info");
                 }else{
                     alertmsg(json.msg,"alert");
                 }
             }
        })
     }
        
     $('#dataorganizations_up_close').click(function(){//关闭
         $("#dataorganizations_dialog_up").dialog('close');
     })
     
     function fun_dataorganizations_update(){//修改操作
        var dataUpdate = $("#dataorganizations_grid").jqGrid('getGridParam','selarrrow');//'selarrrow'     
        var lengthUpdate=dataUpdate.length;
        if(lengthUpdate >1){
  	        alertmsg("每次只能修改一条记录!","alert");
  	        return;
  	    }
        var id =$("#dataorganizations_grid").jqGrid('getGridParam','selrow');
        if(typeof(id) =="string"){
            rowData=jQuery("#dataorganizations_grid").jqGrid('getRowData',id);  
		    $("#dataorganizations_form_up")[0].reset();
		    dataorganizationsdata.upvalidate.resetForm(); //重置验证状态
		    $('#dataorganizations_up_errmsg').html("");
		    dataorganizationsdata.upval=false;
		    $("#dataorganizations_dialog_up").dialog("open");
            load_dataorganizations_data();
        }else{
           alertmsg("请至少选择一条记录再操作!","alert");
        }
	}
	
	function load_dataorganizations_data(){//加载数据
         //$("#dataorganizations_higherId_up").val(rowData.higherId);
         $("#dataorganizations_cpCode_up").val(rowData.cpCode);
         
         $("#dataorganizations_cpName_up").val(rowData.cpName);
         $("#dataorganizations_abbreviation_up").val(rowData.abbreviation);
         $("#dataorganizations_aboutInfo_up").val(rowData.aboutInfo);
         $("#dataorganizations_areaId_up").val(rowData.areaId);
         $("#dataorganizations_citySel_up").val(rowData.areaName);
         //$("#dataorganizations_cpNature_up").val(rowData.cpNature);
         $("#dataorganizations_coopType_up").val(rowData.coopType);
         $("#dataorganizations_beginTime_upString").val(rowData.beginTimeString);
         $("#dataorganizations_contrNo_up").val(rowData.contrNo);
         $("#dataorganizations_contrPeriod_upString").val(rowData.contrPeriodString);
         $("#dataorganizations_corporate_up").val(rowData.corporate);
         $("#dataorganizations_regAddress_up").val(rowData.regAddress);
         $("#dataorganizations_offAddress_up").val(rowData.offAddress);
         $("#dataorganizations_contact_up").val(rowData.contact);
         $("#dataorganizations_mobileNo_up").val(rowData.mobileNo);
         //$("#dataorganizations_modeValue_up").val(rowData.modeValue);
         $("#dataorganizations_phoneValue_up").val(rowData.phoneValue);
        
        if(rowData.cpNature=="SI管理系统"){
             $("#dataorganizations_cpNature_up").val(1);
         }else if(rowData.cpNature=="SI自服系统"){
             $("#dataorganizations_cpNature_up").val(2);
         }else if(rowData.cpNature=="EC自服务系统"){
             $("#dataorganizations_cpNature_up").val(4);
         }else{
             $("#dataorganizations_cpNature_up").val(9);
         }
         
         if(rowData.modeValue=="初始化"){
             $("#dataorganizations_modeValue_up").val(1);
         }else if(rowData.modeValue=="开通"){
             $("#dataorganizations_modeValue_up").val(2);
         }else if(rowData.modeValue=="暂停"){
             $("#dataorganizations_modeValue_up").val(4);
         }else{
             $("#dataorganizations_modeValue_up").val(5);
         }

	}
	
	 dataorganizationsdata.addvalidate = $("#dataorganizations_form_add").validate({//验证
	        errorElement: "div",
            errorPlacement: function(error, element) {
			    $('#dataorganizations_add_errmsg').html("");
				error.appendTo("#dataorganizations_add_errmsg");
				if($.browser.mozilla){//火狐
				    $("#dataorganizations_dialog_add").dialog('option' , 'height',[dataorganizationsaddDialogHeight()+40]);
				}else{
				    $("#dataorganizations_dialog_add").dialog('option' , 'height',[dataorganizationsaddDialogHeight()+50]);
				}
				dataorganizationsdata.addval=true;
			},
			success: function(label) {
			    label.text("验证通过!").removeClass("error").addClass("success");
			    dataorganizationsdata.addval=true;
			},
	        rules:{
	           dataorganizations_areaId_add:{
                   required: true
               },
               dataorganizations_cpCode_add:{
                   required: true
               },
               dataorganizations_cpName_add:{
                   required: true
               },
               dataorganizations_abbreviation_add:{
                   required: true
               },        
               dataorganizations_cpNature_add:{
                   required: true,
                   notEqual: "-1"
               },
               dataorganizations_coopType_add:{
                   required: true
               },
               dataorganizations_contact_add:{
                   required: true
               },
               dataorganizations_mobileNo_add:{
                   required: true
               }
	        }, 
	        messages: {
	            dataorganizations_areaId_add:{
                   required: "地区不能为空"
               },
                dataorganizations_cpCode_add:{
                   required: "公司不能为空"
               },
               dataorganizations_cpName_add:{
                   required: "公司全称不能为空"
               },
               dataorganizations_abbreviation_add:{
                   required: "公司简称不能为空"
               },        
               dataorganizations_cpNature_add:{
                   required: "机构性质不能为空",
                   notEqual: "请选择机构性质"
               },
               dataorganizations_coopType_add:{
                   required: "合作伙伴类型不能为空"
               },
               dataorganizations_contact_add:{
                   required: "联系人不能为空"
               },
               dataorganizations_mobileNo_add:{
                   required: "联系电话不能为空"
               }
	        },
	        onfocusout:false,
		    onsubmit:false
	})
	
	dataorganizationsdata.upvalidate = $("#dataorganizations_form_up").validate({//验证
	        errorElement: "div",
            errorPlacement: function(error, element) {
			    $('#dataorganizations_up_errmsg').html("");
				error.appendTo("#dataorganizations_up_errmsg");
				dataorganizationsdata.upval=true;
			},
			success: function(label) {
			    label.text("验证通过!").removeClass("error").addClass("success");
			    dataorganizationsdata.upval=true;
			},
	        rules:{
               dataorganizations_cpCode_up:{
                   required: true
               },
               dataorganizations_cpName_up:{
                   required: true
               },
               dataorganizations_abbreviation_up:{
                   required: true
               },        
               dataorganizations_cpNature_up:{
                   required: true,
                   notEqual: "-1"
               },
               dataorganizations_coopType_up:{
                   required: true
               },
               dataorganizations_contact_up:{
                   required: true
               },
               dataorganizations_mobileNo_up:{
                   required: true
               },
               dataorganizations_modeValue_up:{
                   required: true,
                   notEqual: "-1"
               }
	        }, 
	        messages: {
                dataorganizations_cpCode_up:{
                   required: "公司不能为空"
               },
               dataorganizations_cpName_up:{
                   required: "公司全称不能为空"
               },
               dataorganizations_abbreviation_up:{
                   required: "公司简称不能为空"
               },        
               dataorganizations_cpNature_up:{
                   required: "机构性质不能为空",
                   notEqual: "请选择机构性质"
               },
               dataorganizations_coopType_up:{
                   required: "合作伙伴类型不能为空"
               },
               dataorganizations_contact_up:{
                   required: "联系人不能为空"
               },
               dataorganizations_mobileNo_up:{
                   required: "联系电话不能为空"
               },
               dataorganizations_modeValue_up:{
                   required: "状态不能为空",
                   notEqual: "请选择状态"
               }
	        },
	        onfocusout:false,
		    onsubmit:false
	})
	
	
	function fun_dataorganizations_delete(){//删除验证
        var data = $("#dataorganizations_grid").jqGrid('getGridParam','selarrrow');//'selrow'
        var length=data.length;
        if(length <1){
	        alertmsg("请至少选择一条记录再操作!","alert");
	        return;
	    }
	    dataorganizationsdata.ids='';
	    for(var i=0;i<length;i++){
	        if(i > 0){
                 dataorganizationsdata.ids += ', ';
            }
            dataorganizationsdata.ids += data[i];
	    }
        confirm("确认要删除所选记录吗？", fun_dataorganizations_del);
        
    }
    
    function fun_dataorganizations_del(){//删除操作
	    $.ajax({
            type: "POST",
            url:"organiza/DataOrganizations/delete.do",
            dataType: "json",
            data:{
                 ids:dataorganizationsdata.ids
            },
            success:function(json){
                 if(json.success){
                      alertmsg(json.msg,"info");
                      $("#dataorganizations_grid").trigger("reloadGrid");
                 }else{
                      alertmsg(json.msg,"alert");
                 }
                 $("#dialogconfirm").html('');
            }
        })
    }
	
	$("#dataorganizations_dialog_add").dialog({//弹出层
		 autoOpen: false,
		 height: dataorganizationsaddDialogHeight(),
		 width: 630,
		 modal: true
	});
	
	$("#dataorganizations_dialog_up").dialog({//弹出层
		 autoOpen: false,
		 height: dataorganizationsupDialogHeight(),
		 width: 630,
		 modal: true
	});
    
    function dataorganizationsaddDialogHeight(){//弹出层高度
        if($.browser.mozilla){//火狐
           return 344;
	    }else{//其它
		   return 346;
	    }
    }

    function dataorganizationsupDialogHeight(){//弹出层高度
        if($.browser.mozilla){//火狐
           return 420;
	    }else{//其它
		   return 430;
	    }
    }

	function fun_dataorganizationsgridResize(){
	    jQuery("#dataorganizations_grid").setGridHeight(mDiv.height-195);
        jQuery("#dataorganizations_grid").setGridWidth(mDiv.width-22);
	}
	
	$("#westDiv").bind("pageResize",function(event){
		 fun_dataorganizationsgridResize();
	})
	
	function dataorganizationsgridWidth(){    
        mDiv.width-22; 
    }
    
    function dataorganizationsgridHeight(){    
        mDiv.height-195;
    }
	
	fun_dataorganizationsgridResize();
	
	$('#s_dataorganizations').click(function(){
         var s_cpName=encodeURI($('#s_dataorganizations_cpName').val());
         var s_areaId=encodeURI($('#s_dataorganizations_areaId').val());
         var s_cpNature=encodeURI($('#s_dataorganizations_cpNature').val());
         
         $("#dataorganizations_grid").setGridParam({url:'organiza/DataOrganizations/list.do?s_cpName='+s_cpName+'&s_areaId='+s_areaId+'&s_cpNature='+s_cpNature});
         $("#dataorganizations_grid").trigger("reloadGrid");
    })
    
	dataorganizationsdata.addset = {
		isSimpleData: true,
		treeNodeKey: "id",
		treeNodeParentKey: "pId",
		fontCss: setFont,
		expandSpeed : "",
		callback: {
			//beforeExpand: function(){return false;},
			//beforeCollapse: function(){return false;},
			click: dataorganizationsaddzTreeOnClick
		}
	}
  	 
  	 function dataorganizationsaddzTreeOnClick(event, treeId, treeNode) {
		if (treeNode) {
			var cityObj = $("#dataorganizations_citySel_add");
			cityObj.attr("value", treeNode.name);
			$("#dataorganizations_areaId_add").val(treeNode.id);
			hideDataorganizationsMenu_add();
		}
	}

	function dataorganizationszreloadaddTree() {
		hideDataorganizationsMenu_add();
		$("#ataorganizations_dMenu_add").zTree(dataorganizationsdata.addset, dataorganizationsdata.addNodes);
	}

	function showDataorganizationsMenu_add() {
	    if(dataorganizationsdata.addval){
	        $("#ataorganizations_add_dm").css({left:"129px", top: "79px"}).slideDown("fast");
	    }else{
	        $("#ataorganizations_add_dm").css({left:"129px", top: "31px"}).slideDown("fast");
	    }
	}
	
	function hideDataorganizationsMenu_add() {
		$("#ataorganizations_add_dm").fadeOut("fast");
	}
  	 
  	 dataorganizationsdata.upset = {
		isSimpleData: true,
		treeNodeKey: "id",
		treeNodeParentKey: "pId",
		fontCss: setFont,
		expandSpeed : "",
		callback: {
			click: dataorganizationsupzTreeOnClick
		}
	}

	function setFont(treeId, treeNode) {
		if (treeNode && treeNode.isParent) {
			return {color: "blue"};
		} else {
			return null;
		}
	}

	function showDataorganizationsMenu_up() {
	    if(dataorganizationsdata.upval){
	        $("#ataorganizations_up_dm").css({left:"129px", top: "79px"}).slideDown("fast");
	    }else{
	        $("#ataorganizations_up_dm").css({left:"129px", top: "31px"}).slideDown("fast");
	    }
	}
	
	function hideDataorganizationsMenu_up() {
		$("#ataorganizations_up_dm").fadeOut("fast");
	}

	function dataorganizationsupzTreeOnClick(event, treeId, treeNode) {
		if (treeNode) {
			var cityObj = $("#dataorganizations_citySel_up");
			cityObj.attr("value", treeNode.name);
			$("#dataorganizations_areaId_up").val(treeNode.id);
			hideDataorganizationsMenu_up();
		}
	}

	function dataorganizationszreloadupTree() {
		hideDataorganizationsMenu_up();
		$("#ataorganizations_dMenu_up").zTree(dataorganizationsdata.upset, dataorganizationsdata.upNodes);
	}
	
	
    $(function() {   
    
    $("#dataorganizations_beginTime_addString").datetimepicker({
        changeMonth: true,
		changeYear: true,
		showSecond: true, //显示秒
        timeFormat: 'hh:mm:ss',//格式化时间
        stepHour: 1,//设置步长
        stepMinute: 1,
        stepSecond: 1,
        showOn: 'button',
        buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true // must 
    })
    
    $("#dataorganizations_contrPeriod_addString").datetimepicker({
        changeMonth: true,
		changeYear: true,
		showSecond: true, //显示秒
        timeFormat: 'hh:mm:ss',//格式化时间
        stepHour: 1,//设置步长
        stepMinute: 1,
        stepSecond: 1,
        showOn: 'button',
        buttonImage: 'images/calendar.gif',
		buttonImageOnly: true
    })
    
    $("#dataorganizations_beginTime_upString").datetimepicker({
        changeMonth: true,
		changeYear: true,
		showSecond: true, //显示秒
        timeFormat: 'hh:mm:ss',//格式化时间
        stepHour: 1,//设置步长
        stepMinute: 1,
        stepSecond: 1,
        showOn: 'button',
        buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true // must 
    })
    
    $("#dataorganizations_contrPeriod_upString").datetimepicker({
        changeMonth: true,
		changeYear: true,
		showSecond: true, //显示秒
        timeFormat: 'hh:mm:ss',//格式化时间
        stepHour: 1,//设置步长
        stepMinute: 1,
        stepSecond: 1,
        showOn: 'button',
        buttonImage: 'images/calendar.gif',
		buttonImageOnly: true
    })
    
		$("body").bind("mousedown", 
			function(event){
				if (!(event.target.id == "menuBtn_dadd" || event.target.id == "ataorganizations_add_dm" || $(event.target).parents("#ataorganizations_add_dm").length>0)) {
					hideDataorganizationsMenu_add();
				}
				if (!(event.target.id == "menuBtn_dup" || event.target.id == "ataorganizations_up_dm" || $(event.target).parents("#ataorganizations_up_dm").length>0)) {
					hideDataorganizationsMenu_up();
				}
			});
	    
	    $.ajax({
            type: "POST",
            url:"sys/SysArea/getAreaTree.do",
            dataType: "json",
            success:function(json){
                 dataorganizationsdata.addNodes =strToObj(json.msg);
                 dataorganizationsdata.upNodes =strToObj(json.msg);
                 dataorganizationszreloadaddTree();
		         dataorganizationszreloadupTree();
            }
       })
    })
    
    $.ajax({
            type: "POST",
            url:"sys/SysArea/getsysAreaComboBox.do",
            dataType: "json",
            success:function(json){
            	 	
                 $("#s_dataorganizations_areaId").append(json.msg);
            }
        });

</script>
